package com.hwua.view;

import com.hwua.domain.Car;
import com.hwua.service.CarService;
import com.hwua.serviceimpl.CarServiceImpl;

import java.util.List;

/**
 * 根据用户id查找指定用户租车记录
 * @author admin
 */
public class FindRecordByUserIdView extends AbstractView{
    private String returnTime;
    private int num2;
    public FindRecordByUserIdView(int num2){
        this.num2=num2;
    }
    @Override
    public AbstractView showView() {
        CarService cs = new CarServiceImpl();
        List<Car> carList = cs.findRecordByUserId(num2);
        System.out.println("=================================================================指定用户的租车记录" +
                "==========================================================================");
        System.out.println("编号\t汽车编号\t汽车名称\t每日租金\t总租金\t\t品牌\t\t类型\t\t备注\t\t用户名\t\t借车时间\t\t\t\t\t还车时间");
        for (Car car : carList) {
            if(car.getReturnTime()==null){
                returnTime="尚未归还";
                System.out.println(car.getRecordId()+"\t\t"+car.getCarId()+"\t\t\t"+car.getCarName()+"\t\t"+car.getDailyRent()+"\t\t"+car.getPayment()+
                        "\t\t\t"+car.getBrand()+"\t\t"+car.getType()+"\t\t"+car.getCarRemark()+"\t"+car.getUserName()
                        + "\t\t"+car.getRentTime()+"\t\t"+returnTime);
                continue;
            }
            System.out.println(car.getRecordId()+"\t\t"+car.getCarId()+"\t\t\t"+car.getCarName()+"\t\t"+car.getDailyRent()+"\t\t"+car.getPayment()+
                    "\t\t"+car.getBrand()+"\t\t"+car.getType()+"\t\t"+car.getCarRemark()+"\t"+car.getUserName()
                    + "\t\t"+car.getRentTime()+"\t\t"+car.getReturnTime());
        }
        nextView=new AdminView();
        return nextView;
    }
}
